package com.chen.apply.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.common.pojo.entity.Reimburse;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface ReimburseMapper extends BaseMapper<Reimburse> {

    /**
     * 根据申请ID计算总报销金额
     * @param applyId 申请ID
     * @return 总报销金额（单位：分）
     */
    @Select("SELECT COALESCE(SUM(amount), 0) FROM reimburse WHERE apply_id = #{applyId}")
    Integer selectTotalReimburseByApplyId(@Param("applyId") Integer applyId);

    /**
     * 根据行程计划ID计算总报销金额
     * @param planId 行程计划ID
     * @return 总报销金额（单位：分）
     */
    @Select("SELECT COALESCE(SUM(amount), 0) FROM reimburse WHERE plan_id = #{planId}")
    Integer selectTotalReimburseByPlanId(@Param("planId") Integer planId);


}
